package com.mashibing.servicedriveruser.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mashibing.internalcommon.constant.CommonStatusEnum;
import com.mashibing.internalcommon.dto.DriverUserWorkStatus;
import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.servicedriveruser.mapper.DriverUserWorkStatusMapper;
import com.mashibing.servicedriveruser.service.DriverUserWorkStatusService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Z先森
 * @since 2022-09-29
 */
@Service
public class DriverUserWorkStatusServiceImpl extends ServiceImpl<DriverUserWorkStatusMapper, DriverUserWorkStatus> implements DriverUserWorkStatusService {
    @Resource
    private DriverUserWorkStatusMapper driverUserWorkStatusMapper;
    @Override
    public ResponseResult changeWorkStatus(DriverUserWorkStatus driverUserWorkStatus) {
        Map<String,Object> map = new HashMap<>();
        map.put("driver_id",driverUserWorkStatus.getDriverId());
        List<DriverUserWorkStatus> workStatuses = driverUserWorkStatusMapper.selectByMap(map);
        DriverUserWorkStatus workStatus = workStatuses.get(0);
        workStatus.setWorkStatus(driverUserWorkStatus.getWorkStatus());
        driverUserWorkStatusMapper.updateById(workStatus);
        return ResponseResult.success("");
    }
}
